package chapter1.date.task;
/*
4：输出今年的星期天都是几号
 */

import java.text.SimpleDateFormat;
import java.util.*;

public class Task4 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        Calendar calendar = Calendar.getInstance();
        SimpleDateFormat a = new SimpleDateFormat("M月dd日");
        System.out.print("请输入年份：");
        String year;
        while (!(year = input.next()).matches("\\d{4}"))
            System.out.println("输入错误，请重新输入：");
        calendar.set(Integer.parseInt(year), 0, 1);
        int weekday = calendar.get(Calendar.DAY_OF_WEEK);
        if (weekday != 1)
            calendar.add(Calendar.DATE, 8 - weekday);
        while (calendar.get(Calendar.YEAR) <= Integer.parseInt(year)) {
            System.out.println(a.format(calendar.getTime()));
            calendar.add(Calendar.DATE, 7);
        }
    }
}
